function addCombo(dstId,prefName) {
	addCombo2(dstId,prefName,"sourceCombo","comboListSize");
}

function addCombo2(dstId,prefName,srcComboName,srcComboListSizeName) {
	var sizeInput = document.getElementById(srcComboListSizeName);
	var comboIndex = sizeInput.getAttribute("value");
	
	var resultCombo = document.createElement("select");
	resultCombo.setAttribute("name",prefName + comboIndex);
	var srcCombo = document.getElementById(srcComboName);
	for (var i = 0; i < srcCombo.childNodes.length; i++) {
		resultCombo.appendChild(srcCombo.childNodes[i].cloneNode(true));
	}
	
	var dstElement = document.getElementById(dstId);
	dstElement.appendChild(resultCombo);
	dstElement.appendChild(document.createElement("br"));
	
	comboIndex++;
	sizeInput.setAttribute("value",comboIndex);
}

function addComposition(dstId,listSizeId,prefName1,prefName2,prefName3) {
	var sizeInput = document.getElementById(listSizeId);
	var componentIndex = sizeInput.getAttribute("value");
	
	var resultNameTextField = document.createElement("input");
	resultNameTextField.setAttribute("name",prefName1 + componentIndex);
	resultNameTextField.setAttribute("type","text");
	resultNameTextField.setAttribute("size","20");
	var resultPercentageTextField = document.createElement("input");
	resultPercentageTextField.setAttribute("name",prefName2 + componentIndex);
	resultPercentageTextField.setAttribute("type","text");
	resultPercentageTextField.setAttribute("size","10");
	var resultUnitTextField = document.createElement("input");
	resultUnitTextField.setAttribute("name",prefName3 + componentIndex);
	resultUnitTextField.setAttribute("type","text");
	resultUnitTextField.setAttribute("size","5");
	
	var dstElement = document.getElementById(dstId);
	dstElement.appendChild(resultNameTextField);
	dstElement.appendChild(resultPercentageTextField);
	dstElement.appendChild(resultUnitTextField);
	dstElement.appendChild(document.createElement("br"));
	
	componentIndex++;
	sizeInput.setAttribute("value",componentIndex);
}

function addFoodComponent(dstId,listSizeId,prefName1,prefName2) {
	var sizeInput = document.getElementById(listSizeId);
	var componentIndex = sizeInput.getAttribute("value");
	
	var resultNameTextField = document.createElement("input");
	resultNameTextField.setAttribute("name",prefName1 + componentIndex);
	resultNameTextField.setAttribute("type","text");
	resultNameTextField.setAttribute("size","20");
	var resultPercentageTextField = document.createElement("input");
	resultPercentageTextField.setAttribute("name",prefName2 + componentIndex);
	resultPercentageTextField.setAttribute("type","text");
	resultPercentageTextField.setAttribute("size","10");
	
	var dstElement = document.getElementById(dstId);
	dstElement.appendChild(resultNameTextField);
	dstElement.appendChild(resultPercentageTextField);
	dstElement.appendChild(document.createElement("br"));
	
	componentIndex++;
	sizeInput.setAttribute("value",componentIndex);
}
